<?php
/**
 * 账户交易流水查询
 * @author Administrator
 *
 */
class report extends CControllerManageBase{
	public function show()
	{
		$model = new integralChangeModel();
		$pageIndex = $this->getRequestData("page","GET",1);
		$pageSize = 10;
		$c = 0;
		
		$s_time=$this->getRequestData("txt_s_time","get",date("Y-m"."-01"));
		$e_time=$this->getRequestData("txt_e_time","get",date("Y-m-d"));
		$owner_card=$this->getRequestData("txt_card_value","get","");
		$cost_type = $this->getRequestData("sel_cast_type","get");
		$shop_name = $this->getRequestData("txt_shop_name","get");
		
		$e_time_old = $e_time;
		$e_time = date("Y-m-d",strtotime($e_time." +1 day"));

		$where = "cost_time>to_date('".$s_time."','yyyy-mm-dd hh24:mi:ss')";
		$where .= " and cost_time<=to_date('".$e_time."','yyyy-mm-dd hh24:mi:ss')";
		
		
		$urlParam["txt_s_time"] = $s_time;
		$urlParam["txt_e_time"] = $e_time_old;
		
		if($cost_type)
		{
			$where .= " and cost_type=".$cost_type;
			$urlParam["sel_cast_type"] = $cost_type;
		}
		
		if($owner_card)
		{
			$where .= " and owner_card='".$owner_card."'";
			
			$urlParam["txt_card_value"] = $owner_card;
		}
		
		if($shop_name)
		{
			$where .= " and (shop_name like '%".$shop_name."%' or shop_simple_name like '%".$shop_name."%')";
			
			$urlParam["txt_shop_name"] = $shop_name;
		}
		
		$this->setViewParam("s_time", $s_time);
		$this->setViewParam("e_time", $e_time_old);
		$this->setViewParam("cost_type", $cost_type);
		$this->setViewParam("owner_card", $owner_card);
		$this->setViewParam("shop_name", $shop_name);
		
		$pageUrl = $this->getUrlParam($urlParam, array("txt_card","txt_owner_name"));
		$pageUrl = $pageUrl? "?".$pageUrl:"";
		
		$list = $model->selectPage($pageIndex,$pageSize,
			"c_id,s_id,pay_id,cost_money,cost_type,cost_time,discount_type,discount_num,owner_card,cost_before_money,cost_shop_before_money,cost_shop_after_money,cost_after_money,cost_money_t,owner_name,shop_simple_name,is_cancel",
		"c.owner_id=o.owner_id and c.shop_id=s.shop_id and ".$where,"c_id desc","",$c,"t_integral_change c, t_owner o,t_shop s");
		$pageStr = CPage::showPage($pageIndex,$pageSize,$c,$pageUrl);

		$pageUrl = $pageUrl?"&page=".$pageIndex:"page=".$pageIndex;

		$this->setMenu("交易流水查询");
		$this->setJsFile(array("/My97DatePicker/WdatePicker.js"));
		$this->setCssBlock(".container{min-width:1430px; width:100%; margin-right:30px;}");
		$this->render("report/list",array("list"=>$list,"pageStr"=>$pageStr,"pageUrl"=>$pageUrl));
	}
}